package com.gt.utils;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * RequestUtil
 */
@Slf4j
public class RequestUtil {

    /**
     * 解析body
     * @param request
     * @return
     */
    public static String body(HttpServletRequest request){
        String body = null;
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
            body = IOUtils.toString(reader);
        }catch (Exception e){
            log.error("com.xynew.utils.RequestUtil.body 获取请求体失败",e);
        }
        return body;
    }

}
